package com.github.aloxc.plugin.restplus.annotations;


import com.github.aloxc.plugin.DonotGuard;


/**
 * jarx方法注解枚举
 * @author leero
 */
public enum JaxrsHttpMethodAnnotation {
    /**
     * GET
     */
    @DonotGuard
    GET("javax.ws.rs.GET", "GET"),

    /**
     * POST
     */
    @DonotGuard
    POST( "javax.ws.rs.POST", "POST"),

    /**
     * PUT
     */
    @DonotGuard
    PUT( "javax.ws.rs.PUT", "PUT"),

    /**
     * DELETE
     */
    @DonotGuard
    DELETE( "javax.ws.rs.DELETE", "DELETE"),

    /**
     * HEAD
     */
    @DonotGuard
    HEAD( "javax.ws.rs.HEAD", "HEAD"),

    /**
     * PATCH
     */
    @DonotGuard
    PATCH("javax.ws.rs.PATCH", "PATCH");

    JaxrsHttpMethodAnnotation(String qualifiedName, String methodName) {
        this.qualifiedName = qualifiedName;
        this.methodName = methodName;
    }

    private String qualifiedName;
    private String methodName;

   public String methodName() {
        return this.methodName;
    }

    public String getQualifiedName() {
        return qualifiedName;
    }

    public String getShortName() {
        return qualifiedName.substring(qualifiedName.lastIndexOf(".")-1);
    }

    public static JaxrsHttpMethodAnnotation getByQualifiedName(String qualifiedName) {
        for (JaxrsHttpMethodAnnotation springRequestAnnotation : JaxrsHttpMethodAnnotation.values()) {
            if (springRequestAnnotation.getQualifiedName().equals(qualifiedName)) {
                return springRequestAnnotation;
            }
        }
       return null;
    }

}